var PP = { 
    WIDTH : 800,
    HEIGHT : 500,
    x : 0,
    y : 0,
    w : 0,
    h : 0,
    context: null,
    canvas: null,
    isPicLoad: false
};

function namespace(arr){
	for(var i = 0, len=arr.length;i<len;i++){
		var frag = arr[i].split(".");
		window[frag[0]] = window[frag[0]] || {};
		var o = window[frag[0]];
		for(var j=1, num=frag.length;j<num;j++){
			o[frag[j]] = o[frag[j]] || {};
			o = o[frag[j]];
		}
	}
}
namespace([
	'Action',
	'Action.widget',
	'Action.adjust',
	'Action.special',
	'Action.util'
]);
Action.util.namespace = namespace;

function init(){
    PP.canvas = $("#canvasBox>canvas")[0];
    PP.context = PP.canvas.getContext("2d");

    Action.work.init();
    Action.adjust.init();
    Action.special.init();
    Action.decoration.init();
    Action.frame.init();

    var innerBox = $('#toolBox>div')[0];
    var categorys = $('#category>li');
    $.each(categorys,function(index,el){
        $(el).click(function(){
            innerBox.style.left = (index*-235)+"px";
            $.each(categorys,function(i,e){
                $(e).removeClass('active');
            });
            $(el).addClass('active');
        }); 
    });
}

$(init);